# ---------- ---------- ---------- ---------- ---------- ----------
#
# fenrispunk
#
# ---------- ---------- ---------- ---------- ---------- ----------


STAGE_DIR=content
BUILD_DIR=output
TEMPLATE_DIR=template


target: help


.PHONY: help
help:
	@echo "Usage: make [PHONY]"
	@sed -n -e '/sed/! s/\.PHONY: //p' Makefile


.PHONY: init
init:
	@mkdir -p src/static/artwork/rob_michaud/
	@git -C lib/fenrispunk-assets pull || git clone https://notabug.org/vaeringjar/fenrispunk-assets.git lib/fenrispunk-assets
	@rsync -av --delete \
            lib/fenrispunk-assets/artwork/rob_michaud/ \
            src/static/artwork/rob_michaud/ \
                || echo "failed to get fenrispunk-assets"
	@touch headlines.org


.PHONY: sitemap
sitemap:
	@fenrisg \
            "sitemap" \
            "src" \
            "etc/templates/sitemap.org" \
            "src/sitemap/index.org" \
            ".."


.PHONY: build-home
build-home:
	@./build_home_page


.PHONY: html
html: build-home
	@rsync -avh --delete src/ $(STAGE_DIR)/
	@cp $(STAGE_DIR)/static/images/favicon.ico $(STAGE_DIR)/favicon.ico
	@cp $(STAGE_DIR)/static/images/default-logo.png $(STAGE_DIR)/banner.png
	@cp $(STAGE_DIR)/static/images/avatar.png $(STAGE_DIR)/logo.svg
	@fenrisg \
            org \
            $(STAGE_DIR)/ \
            etc/templates/fenrispunk.html \
            etc/filters/links-org-to-html.lua \
            dark \
            ./ \
            $(BUILD_DIR)


.PHONY: feed
feed:
	@fenrisg rss output/archive /archive output/feeds/file.rss.xml FenrisPunk 10


.PHONY: build
build: template sitemap html feed


.PHONY: clean
clean:
	@rm -rf $(BUILD_DIR) $(STAGE_DIR) $(TEMPLATE_DIR)


.PHONY: rebuild
rebuild: clean build


.PHONY: template
template:
	@rsync -avh --delete etc/setupfiles/org-publish-project/ $(TEMPLATE_DIR)/
